<?php
define('WWW_PATH', dirname(__FILE__)); // 站点www目录
echo WWW_PATH;
require(WWW_PATH.'/PicThumb.class.php'); // include PicThumb.class.php
require(WWW_PATH.'/ThumbConfig.php');    // include ThumbConfig.php

$logfile = WWW_PATH.'/createthumb.log';  // 日志文件
$source_path = WWW_PATH.'/upload/';      // 原路径
$dest_path = WWW_PATH.'/supload/';       // 目标路径

// 获取图片URI
$relative_url = '1.jpg';

// 获取config
$config = array(
	'type' => 'fit',
	'width' => 100,
	'height' => 100,
	'bgcolor' => '#FF0000'
);
$config = array(
	'type' => 'fit',
	'width' => 200,
	'height' => 200,
	'bgcolor' => '#FFFF00'
);
$config = array(
	'type' => 'crop',
	'width' => 250,
	'height' => 250,
	'watermark' => WWW_PATH.'/watermark.png'
);

// 原图文件
$source = $source_path.$relative_url;

// 目标文件 
$dest = $dest_path.$relative_url;

// 创建缩略图
$obj = new PicThumb($logfile);
$obj->set_config($config);
if($obj->create_thumb($source, $dest)){
    ob_clean();
    header('content-type:'.mime_content_type($dest));
    exit(file_get_contents($dest));
}

?>